<template>
  <tr>
    <td><input type="checkbox" v-model="obj.checked" /></td>
    <td>{{ obj.name }}</td>
    <td>{{ obj.price }}</td>
    <td style="display: flex">
      <Button title="-" @click="obj.num > 1 ? obj.num-- : 1" />
      <span style="padding: 2px">{{ obj.num }}</span>
      <Button title="+" @click="obj.num++" />
    </td>
    <td>{{ obj.price * obj.num }}</td>
    <td>
      <Button title="删除" @click="delBtnFn"></Button>
    </td>
  </tr>
</template>

<script>
import Button from './Button.vue'
import { mapState } from 'vuex'
export default {
  name: 'GoodList',
  props: ['obj', 'index'],
  components: {
    Button,
  },
  methods: {
    delBtnFn() {
      this.goodList.splice(this.index, 1)
    },
  },
  computed: {
    ...mapState(['goodList']),
  },
}
</script>

<style></style>
